<template>
	<div class="item_bg">
		 <div class="img_bg">
      <img class="" src="http://image.utea88.com/statics/pc_newHome_bg_04.png" alt="">
      <div :class="[isActive ? 'animation2' : '', 'big_title']">热点资讯</div>
      <div :class="[isActive ? 'animation1' : '', 'main_section']">
        <div @click="handleClick(item)" class="content_bg" v-for="(item, index) in newsList" :key="index">
          <div class="img_bg"><img :src="item.image" alt=""></div>
          <div class="title">{{ item.name }}</div>
          <div class="time">{{ item.createTime }}</div>
          <div class="line"></div>
          <div class="detail">{{ item.viceName }}</div>
        </div>
      </div>
     </div>
	</div>
</template>

<script>
  import {
		getNewData
	} from "@/api/front-home.js";

	export default {
    name: '',
    props: {
      activeIndex: {
        default: '',
        type: Number,
      },
    },
		components: {
			
		},
    watch: {
      activeIndex(newValue, oldValue) {
        if (newValue == this.index) {
          this.isActive = true
        } else {
          this.isActive = false
        }
      }
    },
		data() {
			return {
        index: 4,
        isActive: false,
        newsList: [],
			}
		},
		methods: {
      handleClick(item) {
        this.$router.push({
          path: "/front-newDetail",
          query: {
            id: item.id
          },
        });
      },
			// 获取新闻
			getTopData() {
				let data = {
					pageNo: 1,
					pageSize: 3,
					code$in: 'news',
				};
				getNewData(data).then((res) => {
					this.newsList = res.list;
				});
			},
  	},
    mounted(){
      
    },
    created() {
      this.getTopData()
    },
	}
</script>

<style scoped lang="scss">
  .item_bg {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .img_bg {
    position: relative;
    width: 100%;
    height: 100%;

    img {
      width: 100%;
      height: 100%;
    }

    // .big_title {
    //   position: absolute;
    //   left: calc((50% - (1120px) / 2));
    //   top: 0;
    //   width: 308px;
    //   height: 105px;
    //   /** 文本1 */
    //   font-size: 72px;
    //   font-weight: 700;
    //   letter-spacing: 5px;
    //   line-height: 105px;
    //   color: rgba(255, 255, 255, 1);
    //   text-align: center;
    //   vertical-align: top;
    // }
  }

  .big_title {
    position: absolute;
    left: calc((50% - (1120px) / 2));
    top: 0;

    width: 308px;
    height: 105px;
    /** 文本1 */
    font-size: 72px;
    font-weight: 700;
    letter-spacing: 5px;
    line-height: 105px;
    color: rgba(255, 255, 255, 1);
    text-align: center;
    vertical-align: top;
  }

  .main_section {
    position: absolute;
    left: calc((50% - (1120px) / 2));
    top: 100%;
    width: 1120px;
    height: 432px;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background: white;

    .content_bg {
      position: relative;
      width: 300px;
      height: 322px;
      cursor: pointer;

      .img_bg {
        width: 300px;
        height: 200px;

        img {
          width: 100%;
          height: 100%;
        }
      }

      .title {
        margin-top: 12px;
        width: 100%;
        height: 24px;
        opacity: 1;
        /** 文本1 */
        font-size: 18px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 24px;
        color: rgba(0, 0, 0, 1);
        text-align: left;
        vertical-align: top;
        @include ellipsis($line: 1);
      }

      .time {
        margin-top: 4px;
        width: 100%;
        height: 19px;
        opacity: 1;
        /** 文本1 */
        font-size: 14px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 19px;
        color: rgba(153, 153, 153, 1);
        text-align: left;
        vertical-align: top;
      }

      .line {
        margin-top: 12px;
        width: 100%;
        height: 1px;
        background-color: rgb(221, 221, 221);
      }

      .detail {
        margin-top: 12px;
        width: 300px;
        height: 38px;
        opacity: 1;
        /** 文本1 */
        font-size: 14px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 19px;
        color: rgba(153, 153, 153, 1);
        text-align: left;
        vertical-align: top;
        @include ellipsis($line: 2);
      }
    }
  }

  .animation1 {
    top: calc((50% - (561px) / 2 + 129px));
    animation: move1 0.5s linear;
  }

  .animation2 {
    top: calc((50% - (561px) / 2));
    animation: move2 0.5s linear;
  }

  @keyframes move1 {
    0% {
      top: 100%;
    }

    100% {
      top: calc((50% - (561px) / 2 + 129px));
    }
  }

  @keyframes move2 {
    0% {
      top: 0;
    }

    100% {
      top: calc((50% - (561px) / 2));
    }
  }
</style>
